﻿namespace MvcXRepairAdmin.Services
{
    using System;
    using System.Collections.Generic;
    using MvcXRepairAdmin.Interfaces;
    using MvcXRepairAdmin.Repository.SQL;
    using XRepair.Models;

    public class ModelService : IModelService
    {
        private ModelDAO _modelRepository;

        public ModelService()
        {
            _modelRepository = new ModelDAO();
        }

        public IEnumerable<Model> GetAllActiveModels()
        {
            return _modelRepository.GetAllActiveModels();
        }

        public bool DeactivateModelByID(int modelId)
        {
            return _modelRepository.DeactivateModelByID(modelId);
        }

        public bool AddNewModel(Model model)
        {
            model.CreatedAt = DateTime.Now;
            return _modelRepository.AddNewModel(model);
        }

        public bool EditModel(Model model)
        {
            model.LastUpdatedAt = DateTime.Now;
            return _modelRepository.UpdateModel(model);
        }
    }
}
